<?php

namespace App\Http\Requests;

class Category extends Base
{

    public function rules()
    {
        $id = $this->get('id');
        $rules = [
            //unique:表名,字段名,排除ID,主键字段,条件字段,条件,
            'name' => 'required|unique:categorys,name,'.$id,
            'pid' => 'required'
        ];
        return $rules;

    }

    public function messages()
    {
        return [
            'name.required' => '请填写类目名称',
            'name.unique'   => '类目名称已存在',
            'pid.required'  => '请选择上级类目',
        ];
    }
}
